<?php

class General extends CModel {
    public $_lang_id = 1;

    public function attributeNames() {
        return array();
    }

    /* ------------------------------------------------------------------------
      Menu
      -----------------------------------------------------------------------*/
    public function getMenuChild($parentId) {
        $model           = new Menu;
        $criteria        = new CDbCriteria();
        $criteria->compare('parent_id', $parentId);
        $criteria->order = 'sort_order ASC';

        return $model->findAll($criteria);
    }

    /**
     * @return array $result['parent_id']['id'] = $title
     */
    public function getMenu() {
        $criteria = new CDbCriteria(array(
            'order' => 'sort_order ASC'
        ));
        $criteria->compare('language_id', $this->_lang_id);

        $model = new Menu();
        $rows   = $model->findAll($criteria);
        $result = array();

        foreach ($rows as $row)
            $result[$row['parent_id']][$row['id']] = array(
                'title' => $row['title'],
                'link' => $row['link'],
            );

        return $result;
    }
    /* ------------------------------------------------------------------------
      //Menu
      -----------------------------------------------------------------------*/

}